""" 

    Quickly show something to user to keep him/her happy during imports.
    
"""

__author__ = "Mikko Ohtamaa <mikko@redinnovation.com>"
__docformat__ = "epytext"
__copyright__ = "Red Innovation Ltd."
__license__ = "BSD"

# Python imports
import os
import sys

# S60 imports
import appuifw
import graphics

def splash(img_name, color=(255, 255, 255)):
    """ Show a splash screen.
    
    @param img_name: Full path to PNG image. str or unicode.
    """
    
    print "Splashing:" + img_name
    # PyS60 exception 
    #img_name = img_name.replace(":", ":\\") 
    #print "img:" + img_name
    
    # Hide softkeys + title
    appuifw.app.body = c = appuifw.Canvas()
    c.clear(color)
    appuifw.app.screen="full"
    img = graphics.Image.open(img_name)
    
    # Back in the days, we used the magic called bit shifts.
    # No divs for poor coders, preciiioous CPU cycles of the orignal 386
    x = (c.size[0] >> 1) - (img.size[0] >> 1)
    y = (c.size[1] >> 1) - (img.size[1] >> 1)
    c.blit(img, target=(x,y)) # put it about mid-screen
    
def unsplash():
    """ Restore app from the splash screen state.
    
    Just reset appuifw.app.body with your own application UI.
    """
    appuifw.app.screen="normal"
    appuifw.app.body = None